package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.ToolCopy;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import com.sojoys.artifact.constant.DataModelKeyEnum;
import java.util.ArrayList;
/**
 * 城市
 */
public class CityCfg extends BaseCfg<CityCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "city";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.CityCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 5;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","区域类型,1:通用区域,2:仅约会区域,3:仅功能区域","区域开放时间类型,1:默认长时间开启,2:每日特定时间开启,3:每周特定时间开启,4:特定时间范围开启","开放时间","进入消耗道具",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","buildType","timeType","openTime","needItem",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","buildType","timeType","openTime","needItem",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,-1400970552,-2077349977,-504645577,865352905,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","int","int","String","Map",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Integer.class,Integer.class,String.class,Map.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 区域类型
	 * 1:通用区域
	 * 2:仅约会区域
	 * 3:仅功能区域
	 */
	private int buildType;
	
	/**
	 * 区域开放时间类型
	 * 1:默认长时间开启
	 * 2:每日特定时间开启
	 * 3:每周特定时间开启
	 * 4:特定时间范围开启
	 */
	private int timeType;
	
	/**
	 * 开放时间
	 */
	private String openTime;
	
	/**
	 * 进入消耗道具
	 */
	private Map needItem;
	
	
	
	public static CityCfg builder() {
		CityCfg cityCfg = new CityCfg();
		return cityCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 区域类型
	 * 1:通用区域
	 * 2:仅约会区域
	 * 3:仅功能区域
	 */
	public int getBuildType() {
		return buildType;
	}
	
	/**
	 * 区域开放时间类型
	 * 1:默认长时间开启
	 * 2:每日特定时间开启
	 * 3:每周特定时间开启
	 * 4:特定时间范围开启
	 */
	public int getTimeType() {
		return timeType;
	}
	
	/**
	 * 开放时间
	 */
	public String getOpenTime() {
		return openTime;
	}
	
	/**
	 * 进入消耗道具
	 */
	public Map getNeedItem() {
		return needItem;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.buildType;
        values[2] = this.timeType;
        values[3] = this.openTime;
        values[4] = this.needItem;
        return values;
	}
	
	protected CityCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.buildType = (int)vals[1];
		this.timeType = (int)vals[2];
		this.openTime = (String)vals[3];
		this.needItem = (Map)vals[4];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.buildType);
        map.put(keys[2], this.timeType);
        map.put(keys[3], this.openTime);
        map.put(keys[4], this.needItem);
        return map;
    }
    
    protected CityCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.buildType = (int)map.get(keys[1]);
   		this.timeType = (int)map.get(keys[2]);
   		this.openTime = (String)map.get(keys[3]);
   		this.needItem = (Map)map.get(keys[4]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.buildType);
        obj.put(keys[2], this.timeType);
        obj.put(keys[3], this.openTime);
        obj.put(keys[4], this.needItem);
        return obj;
    }
    
    protected CityCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.buildType = obj.getIntValue(keys[1]);
	    this.timeType = obj.getIntValue(keys[2]);
	    this.openTime = obj.getString(keys[3]);
		this.needItem = obj.getObject(keys[4],Map.class);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeInt(this.buildType);
	    byteBuf.writeInt(this.timeType);
	    byteBuf.writeString(this.openTime);
	    byteBuf.writeObject(this.needItem);
    }
	
	protected CityCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.buildType = byteBuf.readInt(null);
	    this.timeType = byteBuf.readInt(null);
	    this.openTime = byteBuf.readString(null);
	    this.needItem = (Map)byteBuf.readObject();
	    return this;
	}
	
	public CityCfg deepCopy(){
		CityCfg cityCfg = null;
		try {
			cityCfg = (CityCfg) super.clone();
		    cityCfg.needItem = ToolCopy.copyObject(this.needItem);
			return cityCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return cityCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
